<template>
	<view>
		<uni-list v-for="(item,index) in list">
			<view @longpress="longpress(item.id)">
				<uni-list-item clickable :title="item.EnCode" :show-badge="true" :badge-text="item.count" link :to="'../takestockbodylist/takestockbodylist?id='+item.id" :note="item.CreatorTime" :rightText="item.EnabledMark"></uni-list-item>
			</view>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				EnabledMark:''
			}
		},
		onLoad() {
			this.$api.Request({
				url: "/api/TakeStock/GetTakeStockHeadList",
				method: 'GET',
				data: {},
			}).then((res) => {
		
				res.forEach(item => {
		            if(item.EnabledMark==true){
						this.EnabledMark='开启'
						
					}else{
						this.EnabledMark='关闭'
					}
					this.list.push({
						id: item.Id,
						EnCode: "编号:"+item.EnCode+" 名称:"+item.Name+" 仓库:"+ item.WarehouseName,
						
						EnabledMark: this.EnabledMark,
					
						CreatorTime: this.$dateformat.dateFormat(item.CreatorTime, 'datetime'),
						count: item.BodyCount,
						
					})
				});
		
			})
		
		
		},
		methods: {
			onNavigationBarButtonTap() {
				uni.navigateTo({
					url: '../takestockheadadd/takestockheadadd'
				})
			},
			longpress(id) {
				var me = this;
				uni.showModal({
					title: '删除',
					content: '请问要删除本条消息吗？',
					success: function(res) {
						if (res.confirm) {
							me.$api.Request({
								url: "/api/TakeStock/DeleteHead?keyValue=" + id,
								method: 'GET',
			
							}).then((res1) => {
			
								if (res1.state == 'success') {
									uni.showToast({
										title: `删除成功`
									})
									location.reload();
			
								} else {
									uni.showToast({
										title: `删除失败`,
										icon:'error',
									})
			
								}
			
							})
						}
			
					}
				});
			},
		}
	}
</script>

<style>

</style>
